#os模块:查看一个文件夹下的所有文件，这个文件夹下还有文件，不能用walk
import os
def show_file(path):
    name_lst=os.listdir(path)
    for name in name_lst:
        abs_path=os.path.join(path,name)
        if os.path.isfile(abs_path):
            print(name)
        elif os.path.isdir(abs_path):
            show_file(abs_path)
show_file('D:\AK\函数')

#斐波那契数列
#1 1 2 3 5 8 13
# def fib(n):
#     if n==1:
#         return 1
#     elif n==2:
#         return 2
#     else:
#         return fib(n-1)+fib(n-2)
# res=fib(100)
# print(res)

def fib(n,a=1,b=1):
    if n==1 or n==2:
        return b
    else:
        a=b
        b=a+b
        return fib(n-1,a,b)
res=fib(100)
print(res)
def fib(n):
    a=1
    b=1
    while n>2:
        a,b=b,a+b
        n-=1
    return b
res=fib(100)
print(res)

def fib(n):
    if n==1:
        yield 1
    else:
        yield from(1,1)
        a,b=1,1
        while n>2:
            a,b=b,a+b
            yield b
            n-=1
for i in fib(4):
    print(i)

